home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / devel / db / esm-3.1 / esm-3 / usr / local / sm / src / serverlib / thread / notify.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-05  |  3.4 KB  |  129 lines

  1. /*
  2.  *   $RCSfile: notify.c,v $  
  3.  *   $Revision: 1.1.1.1 $  
  4.  *   $Date: 1996/05/04 21:55:59 $      
  5.  */ 
  6. /**********************************************************************
  7. * EXODUS Database Toolkit Software
  8. * Copyright (c) 1991 Computer Sciences Department, University of
  9. *                    Wisconsin -- Madison
  10. * All Rights Reserved.
  11. *
  12. * Permission to use, copy, modify and distribute this software and its
  13. * documentation is hereby granted, provided that both the copyright
  14. * notice and this permission notice appear in all copies of the
  15. * software, derivative works or modified versions, and any portions
  16. * thereof, and that both notices appear in supporting documentation.
  17. *
  18. * THE COMPUTER SCIENCES DEPARTMENT OF THE UNIVERSITY OF WISCONSIN --
  19. * MADISON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.  
  20. * THE DEPARTMENT DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES
  21. * WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
  22. *
  23. * The EXODUS Project Group requests users of this software to return 
  24. * any improvements or extensions that they make to:
  25. *
  26. *   EXODUS Project Group 
  27. *     c/o David J. DeWitt and Michael J. Carey
  28. *   Computer Sciences Department
  29. *   University of Wisconsin -- Madison
  30. *   Madison, WI 53706
  31. *
  32. *     or exodus@cs.wisc.edu
  33. *
  34. * In addition, the EXODUS Project Group requests that users grant the 
  35. * Computer Sciences Department rights to redistribute these changes.
  36. **********************************************************************/
  37.  
  38. #include "sysdefs.h"
  39. #include "ess.h"
  40. #include "checking.h"
  41. #include "trace.h"
  42. #include "error.h"
  43. #include "list.h"
  44. #include "tid.h"
  45. #include "io.h"
  46. #include "lock.h"
  47. #include "object.h"
  48. #include "msgdefs.h"
  49. #include "thread.h"
  50. #include "bitvec.h"
  51. #include "thread_funcs.h"
  52. #include "thread_globals.h"
  53. #include "threadstate.h"
  54.  
  55.  
  56.  void
  57. notify (
  58.  
  59.     register LIST    *list,
  60.     register int    error,
  61.     register int    eno 
  62.  
  63. )
  64. {
  65.  
  66.     register TCB    *tcb;
  67.  
  68.  
  69.     TRPRINT(TR_THREAD, TR_LEVEL_1, ("error:%d", error));
  70.  
  71.     /*
  72.      *    attempt to get a thread off the ready list
  73.      */
  74.     while ((tcb = (TCB *) listDeq(list)) != NULL)    {
  75.  
  76.         TRPRINT(TR_THREAD, TR_LEVEL_2, ("dispatching thread:%d", tcb->id));
  77.  
  78. #ifdef DEBUG
  79.         /*
  80.          *    Make sure the thread is waiting on something that
  81.          *    notify is currently allowed to wakeup.  Other types
  82.          *    of waiters could be notified, but these are the only
  83.          *    ones in the current implementation.
  84.          */
  85.         switch (tcb->state) {
  86.         case THREAD_SH_LATCH_WAIT:
  87.         case THREAD_EX_LATCH_WAIT:
  88.         case THREAD_LOCK_WAIT:
  89.         case THREAD_LOCKUPGRADE_WAIT:
  90.         case THREAD_LOG_QUIESCE_WAIT:
  91.         case THREAD_LOG_PREFLUSH_WAIT:
  92.         case THREAD_BUFGROUP_WAIT:
  93.         case THREAD_LOG_RECOVERY_WAIT:
  94.         case THREAD_CHECKPOINT_WAIT:
  95.         case THREAD_DISKOPEN_WAIT:
  96.         case THREAD_DISKCLOSE_WAIT:
  97.         case THREAD_LOG_CLOSE_WAIT:
  98.         case THREAD_TRANS_SHUTDOWN_WAIT:
  99.         case THREAD_RECOVER_UNDO_WAIT:
  100.         case THREAD_PAGEFLUSH_WAIT:
  101.         case THREAD_FORK_WAIT:
  102.         case THREAD_COORD_WAIT:
  103.             break;
  104.  
  105.         /* only on error */
  106.         case THREAD_SEMAPHORE_WAIT: 
  107.         case THREAD_DISK_WAIT:
  108.         case THREAD_RECEIVE_WAIT:
  109.         case THREAD_DISK_Q_WAIT:
  110.             SM_ASSERT(LEVEL_3, error != esmNOERROR);
  111.             SM_ASSERT(LEVEL_3, eno != esmNOERROR);
  112.             break;
  113.  
  114.         default:
  115.  
  116.             /* notify is not used to wake these threads */
  117.             SM_ERROR(TYPE_FATAL, esmINTERNAL);
  118.         }
  119. #endif DEBUG
  120.  
  121.         /*
  122.          *    take the thread off the list and put in ready list
  123.          */
  124.         listEnq( &ReadyList, &(tcb->controlList) );
  125.         tcb->error = error;
  126.         tcb->errno = eno;
  127.     }
  128. }
  129.